docs: Be more careful when expanding abbreviations
authorMatthias Clasen <mclasen@redhat.com>
Sun, 24 May 2020 01:33:25 +0000 (21:33 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 25 May 2020 20:11:18 +0000 (16:11 -0400)
We must not expand #symbol in the middle of a url,
where it is probably a fragment identifier. Restrict
problem.

docs/reference/gtk/gtk-markdown-to-docbook

index b461a442304a60cdff673b0698a28697b8196ee0..247c613dceb8437974bc0e6c1e808f0f358c4d40 100755 (executable)
@@ -37,10 +37,13 @@ def ExpandAbbreviations(symbol, text):
     text = re.sub(r'\\\%', r'\%', text)
 
     # Convert '#symbol', but not '\#symbol'.
+
+    # Only convert #foo after a space to avoid interfering with
+    # fragment identifiers in urls
     def f3(m):
         return m.group(1) + MakeHashXRef(m.group(2), "type")
 
-    text = re.sub(r'(\A|[^\\])#([\w\-:\.]+[\w]+)', f3, text)
+    text = re.sub(r'(\A|[ ])#([\w\-:\.]+[\w]+)', f3, text)
     text = re.sub(r'\\#', '#', text)
 
     return text